package com.prj.ufdm.cloud.ms.core.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

@Configuration
public class MainRestTemplateConfig {

	@Bean
	@Primary
	@LoadBalanced
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) 
    {
		RestTemplate  restTemplate=restTemplateBuilder
           .setConnectTimeout(Duration.ofMillis(15000))
           .setReadTimeout(Duration.ofMillis(60000))
           .build();
		return restTemplate;
    }
	
}